package cn.larry.bean;

import javax.annotation.PostConstruct;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 * 演示最常规的构造器。
 * 
 * @author LarryZeal
 *
 */
public class OneBean implements BeanNameAware, BeanFactoryAware, ApplicationContextAware, InitializingBean {

	public OneBean() {
		System.out.println("无参构造方法执行中");
	}

	@PostConstruct
	public void run() {
		System.out.println("@PostConstruct方法执行中");
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		System.out.println("afterPropertiesSet 执行中");
	}

	public void init() {
		System.out.println("init-method 执行中");
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
	 */
	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		System.out.println("ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)");

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.springframework.beans.factory.BeanFactoryAware#setBeanFactory(org.springframework.beans.factory.BeanFactory)
	 */
	@Override
	public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
		System.out.println("BeanFactoryAware#setBeanFactory(org.springframework.beans.factory.BeanFactory)");
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
	 */
	@Override
	public void setBeanName(String name) {
		// TODO Auto-generated method stub
		System.out.println("BeanNameAware#setBeanName(java.lang.String)");
	}

}
